package com.bms.hystrix.service.lts;

import com.bms.hystrix.interfaces.lts.ServiceFeignByCheck;
import com.bms.hystrix.pojo.ShiPinBiao;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Map;

/**
 * @version 1.0
 * @auther pickingstars
 * @description CheckService.java
 * @date 2021/3/26 15:15
 */
@Service
public class CheckService {
    @Resource
    private ServiceFeignByCheck serviceFeignByCheck;


    // 通过feign调用服务模块，如果触发熔断机制，则会调用此注解fallbackMethod定义的方法
//    @HystrixCommand(fallbackMethod = "checkError")
//    public Map check(String yongHuMingCheng) {
//        return serviceFeignByCheck.selectClient(yongHuMingCheng);
//    }

    public Map checkError(String name) {
        Map map = new HashMap();
        map.put("code", 500);
        map.put("msg","服务异常，请稍后重试！");
        map.put("name", name);
        return map;
    }

//    @HystrixCommand(fallbackMethod = "chaXunFenYe")
public Map chaXunFenYe(@RequestParam(name = "page") int page, String mingCheng) {
    return this.serviceFeignByCheck.chaXunFenYe(page, mingCheng);
}

    //@HystrixCommand(fallbackMethod = "shanChuById")
    public  Map shanChuById(String id) {
        return serviceFeignByCheck.shanChuById(id);
    }

   // @HystrixCommand(fallbackMethod = "gengXinById")
    public  Map gengXinById(ShiPinBiao shiPinBiao) {
    return serviceFeignByCheck.gengXinById( shiPinBiao);
    }

   // @HystrixCommand(fallbackMethod = "xinZeng")
    public  Map xinZeng(ShiPinBiao shiPinBiao) throws FileNotFoundException {
        return serviceFeignByCheck.xinZeng(shiPinBiao);
    }

   // @HystrixCommand(fallbackMethod = "taoLunLiangById")
    public  Map taoLunLiangById( ShiPinBiao shiPinBiao) {
        return serviceFeignByCheck.taoLunLiangById(  shiPinBiao );
    }

   // @HystrixCommand(fallbackMethod = "xiaZaiLiangById")
    public  Map xiaZaiLiangById( ShiPinBiao shiPinBiao) {
        return serviceFeignByCheck.xiaZaiLiangById(  shiPinBiao );
    }

   // @HystrixCommand(fallbackMethod = "boFangLiangById")
    public  Map boFangLiangById( ShiPinBiao shiPinBiao) {
        return serviceFeignByCheck.boFangLiangById(  shiPinBiao );
    }

   // @HystrixCommand(fallbackMethod = "xiaZaiShiPin")
    public  Map xiaZaiShiPin( String diZhi) {
        return serviceFeignByCheck.xiaZaiShiPin(diZhi );
    }


}